package com.woddp.test1;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(Test1Properties.class)
@ConditionalOnClass(TestService.class)
@ConditionalOnProperty(prefix = "spring.test1", value = "enabled", matchIfMissing = true)
public class TestAutoConfiguration {

    @Autowired
    private Test1Properties properties;

    @Bean
    @ConditionalOnMissingBean(TestService.class)
    public TestService testService() {
        TestService testService = new TestService(properties);
        return testService;
    }

}
